package test;

import java.rmi.AccessException;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.util.ArrayList;
import java.util.ResourceBundle;

import rmi.ServeurRmiInterface;
import bean.Ordonnance;

public class ClientRmi {
	private static String ficConfig = "rmi";

	public static void main(String[] args) {
		ResourceBundle rs = ResourceBundle.getBundle(ficConfig);
		int port = Integer.parseInt(rs.getString("port"));
		String nom = rs.getString("nom");
		try {
			Registry registry = LocateRegistry.getRegistry(port);
			ServeurRmiInterface serveur = (ServeurRmiInterface) registry
					.lookup(nom);
			ArrayList<Ordonnance> liste = serveur.rechercherOrdonnance(2, 0,
					50);
			for (Ordonnance ordonnance : liste) {
				System.out.println(ordonnance);
			}
		} catch (AccessException e) {
			e.printStackTrace();
		} catch (RemoteException e) {
			e.printStackTrace();
		} catch (NotBoundException e) {
			e.printStackTrace();
		}
	}
}
